//用于正确镶嵌六边形瓦片
//用法：初始化引擎，设置六向接壤，设置X向接壤，获取索引字符串
var terrainIndexEngine = {
	_intTag : 0,
	
	_IndexToString : function(index){
		index--;
		var y = Math.floor(index / 8);
		var x = index % 8;
		return "0"+y+"0"+x;
	},
	
	ClearTag : function(){
		this._intTag = 0;
	},
	
	SetAllheadingTag : function(){
		this._intTag = 63;
	},
	
	SetTerrainTag : function(heading, boolSameType){
		if (boolSameType)
			this._intTag += Math.pow(2, heading);
	},
	
	GetIndexString : function(){
		if (this._intTag == 0){
			return this._IndexToString(64);
		}else if (this._intTag == 63){
			return this._IndexToString(65 + Math.floor(Math.random() * 16));
		}else{
			return this._IndexToString(this._intTag);
		}
	}
}